Computer processors typically execute binary code encoded in a particular instruction set. Binary translation translates binary code targeted for a particular instruction set into translated binary code, generally targeted for another instruction set. Binary translation may be used to enable backward- or forward-compatibility for software applications, or to improve processing efficiency. For example, binary code targeted for a reduced instruction set computing (RISC) architecture such as PowerPC may be translated into binary code targeting a complex instruction set computing (CISC) architecture such as IA-32, allowing legacy applications to run on newer hardware. As another example, binary translation may generate translated binary code targeting the same computer architecture but optimized by using newer features such as wider instructions, improved vector instructions, or the like. Binary translation may be dynamic, that is, the code may be translated as it is executed. For some systems, binary translation software may execute close to the hardware, transparent to any operating system or virtual machine monitor (VMM).
Some binary translation systems provide partial translation. In such systems, the processor may execute binary code natively until a code “hotspot” is detected. The hotspot may be any segment of code that may benefit from optimization through binary translation. Upon detecting the hotspot, the system analyzes the native code, translates the native code to translated code, and installs the translated code in a translation cache (a “T-cache”). After translation, the processor executes the translated code instead of native code whenever the hotspot is encountered. Binary translation systems also may account for self-modifying code; that is, executable code that modifies itself at runtime. Translated code regions that are affected by self-modifying code are typically invalidated.